<template>
<div class="page" data-name="order-confirm">
  <div class="navbar">
    <div class="navbar-inner">
      <div class="left">
      	 <a href="#" class="link back">
           <i class="icon icon-back"></i>
         </a>
      </div>
      <div class="title">
      	评价
      </div>
      <div class="right">
      	<a>发布</a>
      </div>
    </div>
  </div>
  <div class="page-content">
  	<div class="order-product-assess-container">
				
	</div>	
  </div>
</template>


<script>

/*
   * 根据index获取 str
   * **/
  function byIndexLeve(index){
    var str ="";
    switch (index)
    {
      case 0:
        str="一星";
        break;
      case 1:
        str="二星";
        break;
      case 2:
        str="三星";
        break;
      case 3:
        str="四星";
        break;
      case 4:
        str="五星";
        break;
    }
    return str;
  }

function listOrderAssessProduct(orderId){
	  var  orderProductListResult = [{orderId:1},{orderId:2}];
      var recommendOrderProductAssessListTemplate = $$('#orderProductAssessTemplate').html();
      var compiledRecommendOrderProductAssessTemplate = Template7.compile(recommendOrderProductAssessListTemplate);
      var innerHTML = compiledRecommendOrderProductAssessTemplate({orderProductList:orderProductListResult});
      $$(".order-product-assess-container").append(innerHTML);
}

  return {
  	on:{
  		 pageInit: function () {
  	        self = this;
  	        app = self.$app;
  	        router = self.$router;
  	        
  	        
  	      	listOrderAssessProduct(1);
  	      
	  	    // 星星数量
	  	    var stars = [
	  	  	  ['x2.png', 'x1.png', 'x1.png', 'x1.png', 'x1.png'],
	  	      ['x2.png', 'x2.png', 'x1.png', 'x1.png', 'x1.png'],
	  	      ['x2.png', 'x2.png', 'x2.png', 'x1.png', 'x1.png'],
	  	      ['x2.png', 'x2.png', 'x2.png', 'x2.png', 'x1.png'],
	  	      ['x2.png', 'x2.png', 'x2.png', 'x2.png', 'x2.png'],
	  	    ];
	  	    $$(".order-evaluation li").find("img").click(function() {
	  	      var obj = $$(this);
	  	      var li = obj.closest("li");
	  	      var star_area_index = li.index();
	  	      var index1 = obj.index();
	  	      li.attr("data-default-index", (parseInt(index1)+1));
	  	      var index = $$(this).parent().parent().attr("data-default-index");//点击后的索引
	  	      index = parseInt(index);
	  	      console.log("index",index);
	  	      $$(this).parent().parent().find(".level").html(byIndexLeve(index-1));
	  	      console.log(byIndexLeve(index-1));
	  	      $$(this).parent().parent().find("img").attr("src","img/x1.png");
	  	      for (var i=0;i<index;i++){
	  	    	$$(this).parent().parent().find("img").eq(i).attr("src","img/x2.png");
	  	      }
	  	    });
  	      
  	        
  		 }
  	}
	
  };
</script>
